version 14.1
set more off

***************************************************************************************************
*THIS FILE PRODUCES TABLE A.XXI OF SLEMROD-REHMAN-WASEEM-2020, RESTAT
***************************************************************************************************

/* PRELIMINARIES */

use				"$project_data\ITRM_Dislo_Unique_Top1000_Corporate_Master.dta", clear
#d				;
matrix 			input table=(0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0\
							 0,0,0,0,0,0,0,0,0,0,0,0\0,0,0,0,0,0,0,0,0,0,0,0);
#d				cr

/* DEFINE TREATMENT VARIABLE */

qui				tab year, g(ydum)
g				after=year>=2012
g				mc=(it_office_id==1 | it_office_id==6 | 					///
				it_office_id==10 | it_office_id==16 | it_office_id==66 			///
				| it_office_id==70 | it_office_id==74 | it_office_id==97 		///
				| it_office_id==9 | it_office_id==20)
g 				double bdate=dofc(birth_foundation_date)
g 				byear=year(bdate)
g 				age=2016-byear								
qui				sum age,d
g				young=(age<=r(p50))		

/* COLUMN 1 (Baseline) */

local			j=1
g				treat=(rank>80 & rank<=120)
g				treat_after=treat*after
qui				reg logdelT i.year treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 2 (With MC X YEAR Fixed Effects) */

qui				xi: reg logdelT i.year*i.mc treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 3 (With Young x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.young treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 4 (With Public Limited x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.public treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 5 (With Bank x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.bank treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 6 (With Textile x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.textile treat treat_after, cluster(regno)
local			i=1
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

*----------------------------
/* PLACEBO SPECIFICATION */
*----------------------------

drop			if year>=2011
drop			treat after treat_after
g				after=year>=2009
g				treat=(rank>80 & rank<=120)
g				treat_after=treat*after

/* COLUMN 1 (Baseline) */

local			j=1
qui				reg logdelT i.year treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 2 (With MC X YEAR Fixed Effects) */

qui				xi: reg logdelT i.year*i.mc treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 3 (With Young x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.young treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 4 (With Public Limited x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.public treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 5 (With Bank x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.bank treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* COLUMN 6 (With Textile x Year Fixed Effects) */

qui				xi: reg logdelT i.year*i.textile treat treat_after, cluster(regno)
local			i=4
matrix			table[`i',`j']=_b[treat_after]
matrix 			table[`i'+1,`j']=_se[treat_after]
matrix			table[`i'+2,`j']=e(N)
local			j=`j'+1

/* FORMATTING THE TABLE */ 

svmat 			table
keep			tab*
drop			table7-table12
keep			if _n<=6
g				c11=""
replace			c11="treat $\times$ after" in 1
replace			c11="Observations" in 3
replace			c11="treat $\times$ after" in 4
replace			c11="Observations" in 6

forvalues 		c=1/6 {
g				c`c'=string(table`c',"%9.3f")
}
foreach			r in 2 5 {
forvalues		c=1/6 {
replace			c`c'="("+string(table`c',"%9.3f")+")" in `r'
}
}
forvalues		c=1/6 {
replace			c`c'=string(table`c',"%15.0fc") in 3
replace			c`c'=string(table`c',"%15.0fc") in 6
}
forvalues		s=1/15 {
g				s`s'="&"
}
g				l="\\"
foreach			r in 2 3 5 6 {
replace			l="\\\\" in `r'
}
order			c11 s11 c1 s1 c2 s2 c3 s3 c4 s4 c5 s5 c6 l
browse			c11 s11 c1 s1 c2 s2 c3 s3 c4 s4 c5 s5 c6 l

